package controller;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import common.DbUtil;
import json.DatatablesFormatter;
import json.JSONParam;
import json.JSONResponse;


@Controller
@RequestMapping("/taskInfo")
public class TaskInfoController extends JSONController {
	
	@RequestMapping(value = "/search", method = RequestMethod.POST)
	@ResponseBody
	public JSONResponse search(@RequestBody JSONParam[] params) throws IllegalAccessException, InvocationTargetException {
		HashMap<String, String> paramMap = convertToMap(params);
		System.err.println(paramMap);
		String sEcho = paramMap.get("sEcho");
		String task_id = paramMap.get("task_id");
		
		//System.err.println("task_id:"+task_id);
		//List<Object> userList = userService.search("from vo.User where account like '%"+userName+"%'",new String[]{userName}, start, length);
		
		Object[] obj=new Object[1];
		obj[0]="%"+task_id+"%";
		List taskList=DbUtil.getJdbcTemplate().
			queryForList("select task_id,task_system,module_id,function_name,task_stage,task_state,charge_man from task_info where task_id like ?", obj);
		
		return successed(DatatablesFormatter.getFormatData(taskList, paramMap));
	}
	/*
	 update task_info a , sys_param_value b set a.module_id=b.param_code
	 where a.module_id=b.param_value and b.param_type_code='module_id';
	 
	 update task_info a , sys_param_value b set a.task_stage=b.param_code
	 where a.task_stage=b.param_value and b.param_type_code='TASK_STAGE';
	 
	 update task_info a , sys_param_value b set a.task_state=b.param_code
	 where a.task_state=b.param_value and b.param_type_code='task_state';
	 */
}